package lxh.grails.basic;


def c1 = {name ->
		println "Hello $name";
}
c1("aaa")

c1 = {name, greeting ->
	println name+" "+greeting;
}
c1("groovy", "hello")

c1 = {
	println it;
}
c1("testit")
c1();

c2 = {
		println "call closure";
}
def callC(action)
{
	action.call();
}
callC(c2)
callC({println "direct call"})

[1,2,3].find{x ->
	if(x == 3)
		println x;
}
def c3 = {x ->
if(x == 3)
	println x;
}
[1,2,3].find(c3);

(1..10).each{print it+" "}
println "";
10.times{ print it+" " }
println "";
1.upto(10){ print it+" " }
println "";
1.step(10,1){ print it+" " }

println();println "///////////////////////////////////////";

def square = { it * it }
def list10 = [1,2,3];
def list11 = list10.collect(square);
list11.each
{
	print it
}
list10.each
{
	print it
}
